package xyz.talentboy.common.config;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.Charset;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

@Configuration
public class ConfigBean {

	
	@Bean
	public RestTemplate registRestTemplate() {
		try {
			Field field = StringHttpMessageConverter.class.getField("DEFAULT_CHARSET");
			field.setAccessible(true);
			Field modifiersField = Field.class.getDeclaredField("modifiers");
			modifiersField.setAccessible(true);
			modifiersField.set(field, field.getModifiers() & ~Modifier.FINAL);
			field.set(Charset.class, Charset.forName("UTF-8"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		RestTemplate restTemplate = new RestTemplate();
		return restTemplate;
	}
	

}
